<?php
include_once("../function.php");
include_once("../class/bonus_class.php");
include_once ("../class/system_class.php");
include_once ("../class/ulevel_class.php");
header("Content-Type: text/html;charset=utf-8");

$dateymd=date("Y-m-d");
$date=strtotime($dateymd);
    $isbobi=0;
    $ffmey=59800;

    $_bonus_cl=new bonus_class();
    $sql="select id,pdt,chl2,istiche from member where ispay>0";
    $query=mysql_query($sql);
    $us=getMemberbyID(1);
    $xingqi = date("w");
    $_system=new system_class();
    $system=$_system->system_information(1);
    $time=unserialize($system['jingtaitime']);
    $sql1="select count(*) as cs from member where ispay>0 and ulevel=1";
    $c1=getOne($sql1);
    $sql2="select count(*) as cs from member where ispay>0 and ulevel=2";
    $c2=getOne($sql2);
    $sql3="select count(*) as cs from member where ispay>0 and ulevel=3";
    $c3=getOne($sql3);
    $zong=$c1['cs']+$c2['cs']*3+$c3['cs']*5;
    if(in_array($xingqi, $time) || $time[0] == 8){
        if ($us['chl2'] < $date) {

            while ($rs = mysql_fetch_assoc($query)){
            //    if(!empty($rs['chl2'])){
               //     $jihuo10=strtotime('+36 day',$rs['chl2']);
                //    $time=time();
                  //  if($jihuo10<=$time){
                        if($rs['istiche']==1){
                            $_bonus_cl->b1bonus($rs['id'],$ffmey,$zong);
                            if($isbobi==1){
                                $_bonus_cl->b0bonus();
                            }else{
                                $_bonus_cl->b0bonusjingtai();
                            }

                        }

               //     }
          //      }
            }
            edit_sql("update `member` set chl2=" . $date . " where id=1");
            file_put_contents('c:\\426.txt', date('Y-m-d H:i:s') . '发放成功\r\n', FILE_APPEND);
        }
    }

    $_bonus_cl->b4bonus($ffmey);
if($isbobi==1){
    $_bonus_cl->b0bonus();
}else{
    $_bonus_cl->b0bonusjingtai();
}
edit_sql("update member set zb4=0 where id=1");


